<template>
  <div class="all-boxf">
    <div class="boxerick1">
      <echarts2 id="echartsRisk1" :option="option4" :styles="styles1"></echarts2>
    </div>
    <div class="boxerick2">
      <echarts2 id="echartsRisk2" :option="option5" :styles="styles1"></echarts2>
    </div>
  </div>
</template>

<script>
import echarts from "echarts";
import echarts2 from "@/components/echarts.vue";

export default {
  name: "projectrick",
  props: {
    chartDataOne1: {
      type: Array,
      default: () => {
        return [];
      }
    },
    chartDataOne2: {
      type: Array,
      default: () => {
        return [];
      }
    },
    nameList: {
      type: Array,
      default: () => {
        // return ["桥梁工程", "隧道工程", "路基工程", "临建工程"];
        return [];
      }
    },
    pieNameList: {
      type: Array,
      default: () => {
        // return ["I 级风险", "II 级风险", "III 级风险", "IV 级风险"];
        return [];
      }
    },
    pieData:  {
      type: Array,
      default: () => {
        // return ["I 级风险", "II 级风险", "III 级风险", "IV 级风险"];
        return [];
      }
    }
  },
  data() {
    var colors = ["#7cf317", "#d10eb1", "#4ddbff"];
    return {
      dateList: ["今日", "本周", "本月"],
      isActive: 0,
      styles1: {
        width: "100%",
        height: "100%",
        margin: "0 auto"
      },
      option4: {
        barWidth: 10,
        // barGap:'80%',
        legend: {
          textStyle: {
            color: "#fff"
          },
          icon: "roundRect", //  字段控制形状  类型包括 circle，rect,line，roundRect，triangle，diamond，pin，arrow，none
          itemWidth: 16, // 设置宽度
          itemHeight: 6, // 设置高度
          itemGap: 20, // 设置间距
          top: 2,
          // bottom: 2,
          data: ["总数量", "现在时态数"]
        },
        xAxis: {
          type: "category",
          data: this.nameList,
          // data: ["桥梁工程", "隧道工程", "路基工程", "临建工程"],
          // 去掉y轴坐标线
          axisLine: {
            show: false
          },
          axisTick: {
            show: false
          },
          // 设置字体
          axisLabel: {
            show: true,
            textStyle: {
              color: "#ffffff",
              fontSize: 12
            }
          }
        },

        series: [
          {
            name: "总数量",
            type: "bar",
            // data: [600, 900, 1100, 700],
            data: this.chartDataOne1,
            itemStyle: {
              normal: {
                barBorderRadius: [3, 3, 0, 0],
                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                  {
                    offset: 0,
                    color: "#44F0FF"
                  },
                  {
                    offset: 1,
                    color: "#3486DA"
                  }
                ])
              }
            }
          },
          {
            name: "现在时态数",
            type: "bar",
            // data: [300, 500, 600, 700],chartDataOne2
            data: this.chartDataOne2,
            itemStyle: {
              normal: {
                barBorderRadius: [3, 3, 0, 0],
                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                  {
                    offset: 0,
                    color: "#3737FD"
                  },
                  {
                    offset: 1,
                    color: "#3486DA"
                  }
                ])
              }
            }
          }
        ],
        yAxis: [
          {
            type: "value",
            // max : 1200,
            // min: 400,
            splitNumber: 4,
            // 去掉刻度
            axisTick: {
              show: false
            },
            bottom: 10,
            // show : false,
            // 去掉y轴坐标线
            axisLine: {
              show: false
            },
            //网格样式
            splitLine: {
              show: true,
              lineStyle: {
                color: ["#0d1b4b"],
                width: 1,
                type: "solid"
              }
            },
            // 设置字体
            axisLabel: {
              show: true,
              textStyle: {
                color: "#ffffff",
                fontSize: 12
              }
            }
          }
        ],
        // 设置图标的位置
        grid: {
          x: 50,
          x2: 40,
          // y:10,
          y2: 10,
          containLabel: true
        }
      },
      option5: {
        barWidth: 10,
        // barGap:'80%',
        title: {
          text: "风险",
          color: "#fff",
          left: "66%",
          top: "45%",
          textStyle: {
            color: "#fff",
            fontSize: 12
          }
        },
        tooltip: {
          // trigger: 'item',
          formatter: " {b}<br/>{c}<br/> ({d}%)"
        },
        legend: {
          orient: "vertical",
          x: 40,
          y: "center",
          icon: "roundRect", //  字段控制形状  类型包括 circle，rect,line，roundRect，triangle，diamond，pin，arrow，none
          itemWidth: 12, // 设置宽度
          itemHeight: 4, // 设置高度
          itemGap: 10, // 设置间距
          data: this.pieNameList,
          // data: ["I 级风险", "II 级风险", "III 级风险", "IV 级风险"],
          textStyle: {
            color: "#fff"
          }
        },
        series: [
          {
            type: "pie",
            radius: ["30%", "50%"],
            center: ["70%", "50%"],
            borderWidth: 10,
            avoidLabelOverlap: false,
            data: this.pieData,
            /* [
              { value: 335, name: "I 级风险", itemStyle: { color: "#D32F30" } },
              {
                value: 200,
                name: "II 级风险",
                itemStyle: { color: "#F28C1D" }
              },
              {
                value: 145,
                name: "III 级风险",
                itemStyle: { color: "#FFF45C" }
              },
              { value: 120, name: "IV 级风险", itemStyle: { color: "#0041FB" } }
            ],
            */
            itemStyle: {
              // 此配置
              normal: {
                borderWidth: 4
                // borderColor: '#ffffff',
              },
              emphasis: {
                borderWidth: 0,
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(0, 0, 0, 0.5)"
              }
            }
          }
        ]
      }
    }
  },
  components: {
    echarts2
  },
  methods: {
    tabClick(index) {
      this.isActive = index;
    }
  }
};
</script>
<style lang="scss" scoped>
.all-boxf {
  .boxerick1 {
    // background: pink;
    width: 100%;
    height: 50%;
    border-bottom: 0.5px dashed #0ADAFF;
  }
  .boxerick2 {
    // background: pink;
    width: 100%;
    height: 50%;
  }
  width: 100%;
  height: calc(100% - 24px);
}
</style>
